package com.lie.prepare.multi_thread.task;

/**
 * Created by lie on 2018/4/9.
 */
public class LiftOff implements Runnable {

    //标记线程id用的，但这并不是线程安全的（只要以多线程形态启动new thread来加载这个runnable就是不安全的）
    private static int taskCount = 1;
    private final int id = taskCount++;

    private int countDown = 10;//default

    public LiftOff() {
    }

    public LiftOff(int countDown) {
        this.countDown = countDown;
    }

    //任务
    public void run() {
        while (countDown-- > 0) {
            System.out.println("id = "+ id + ", lift to "+ countDown);
            Thread.yield();
        }
        System.out.println("id = "+ id + "liftoff");
    }
}
